<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$title}|验证口令</title>
    <meta name="keywords" content="{$keywords}"/>
    <meta name="description" content="{$description}"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{__LIBS__}layui/css/layui.css"/>
    <link rel="stylesheet" href="{__MODULE__}admin.css?v=318"/>
    <style>
        #formBasForm {
            max-width: 700px;
            margin: 30px auto;
        }

        #formBasForm .layui-form-item {
            margin-bottom: 25px;
        }
        .sf-avatar {
            display: inline-block;
            text-align: center;
            background: #ccc;
            color: #fff;
            white-space: nowrap;
            position: relative;
            overflow: hidden;
            vertical-align: middle;
            width: 32px;
            height: 32px;
            line-height: 32px;
            border-radius: 50%;
        }
        .sf-avatar.sf-avatar-icon {
            font-size: 12px;
        }
        .sf-avatar-small {
            width: 24px;
            height: 24px;
            line-height: 24px;
            border-radius: 50%;
        }
        .sf-avatar-small.ivu-avatar-icon {
            font-size: 12px;
        }
        .images {
            background-color: #C9BDBB;
            filter: blur(0px);
        }
    </style>
</head>
<body style="background-image: url('{__IMG__}background.svg');background-size: cover;">
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-col-md6 layui-col-md-offset3">
            <div class="layui-card layui-hide" id="loading" style="opacity: 0.95">
                <div class="layui-card-body images" style="color:black;background-image: url('https://bing.ioliu.cn/v1/rand?h=70');">
                    <img style="border-radius:50%;width:50px;height:50px;"  src="{__IMG__}logo.png" alt="SF">
                    <b style="color:#fff;font-size: 18px">登陆口令验证</b>
                    <span id="tip" class="pull-right">
                        <i class="sf-avatar sf-avatar-icon sf-avatar-small layui-icon layui-icon-help" style="position: relative;top: 12px;color: rgb(255, 169, 64); background-color: rgb(255, 247, 230);"></i>
                    </span>
                </div>
                <div class="layui-card-body">
                    <form class="layui-form layui-form-pane" id="formBasForm" lay-filter="formBasForm">
                        <div class="layui-form-item">
                            <blockquote class="layui-elem-quote-sf-danger">无访问权限！，您的IP：<b>{:get_client_ip()}</b> 已被记录
                            </blockquote>
                            <blockquote class="layui-elem-quote-sf-warning">
                                若您记得目录保护密码，也可访问：http://{:DOMAIN}/admin/Login?登录口令 ，进入登录哦~
                            </blockquote>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">口令</label>
                            <div class="layui-input-block">
                                <input type="password" name="SF_LOGIN_KEY" class="layui-input"  placeholder="请输入登陆口令" required/>
                            </div>
                        </div>
                        <div class="layui-form-item layui-row layui-col-space10 ">
                            <div class="layui-col-md2">
                                <button type="button" class="layui-btn layui-btn-fluid" id="noticeBtn" lay-filter="noticeBtn">&emsp;验证&emsp;</button>
                            </div>
                            <div class="layui-col-md2">
                                <button type="reset" id="formreset" class="layui-btn layui-btn-primary layui-btn-fluid">&emsp;重置&emsp;</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="//lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="{__LIBS__}layui/layui.js"></script>
<script type="text/javascript" src="{__JS__}common.js?v=318"></script>
<script>
    layui.use(['layer', 'form', 'admin', 'notice'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var notice = layui.notice;

        $('#loading').removeClass('layui-hide');

        $('#formreset').click(function () {
            document.getElementById("formBasForm").reset();
            notice.msg('重置表单成功！', {icon: 1});
        });
        $("#tip").click(function (){
            layer.open({
                type: 1,
                area:['300px',''],
                title:'忘记口令',
                closeBtn:0,
                btn:['知道了'],
                content: '<div class="layui-card-body"><blockquote class="layui-elem-quote-sf-info" >方法一：进入数据库找到数据表SF_config，在找到字段SF_Login_Key，修改口令或清空（清空后登陆免验证口令）<br><br>方法二：进入数据库找到数据表SF_config，在找到字段is_SF_Login_Key，把数字1改成数字0即可免验证口令</blockquote></div>'
            });
        });
        layer.tips('忘记登陆口令点这里', '#tip', {
            tips: 3
        });
        $('#noticeBtn').click(function () {
            var SF_LOGIN_KEY = $("input[name='SF_LOGIN_KEY']").val();
            if (SF_LOGIN_KEY == "") {
                notice.warning({
                    title: 'SF提示您',
                    message: '请填写登录口令！',
                    animateInside:true,
                    position:'topCenter',
                    transitionOut:'flipOutX',
                    transitionOutMobile: 'flipOutX',
                    displayMode:'2',
                    audio:'1'
                });
                return false;
            }
            admin.showLoading('#loading', 2, '.8');
            admin.btnLoading('[lay-filter="noticeBtn"]','提交中');
            $.ajax({
                type: "POST",
                url: "{:url('/Login/checkLoginKey')}",
                data : {SF_LOGIN_KEY:SF_LOGIN_KEY},
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        notice.success({
                            title: 'SF提示您',
                            message: data.msg,
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                        setTimeout(function() {
                            notice.msg('正在为您跳转登录页面...', {icon: 4, close: true, audio:'1'});
                        }, 450);
                        setTimeout(function() {
                            location.href="{:url('/Login/index')}";
                        }, 1500);
                    } else {
                        notice.error({
                            title: 'SF提示您',
                            message: data.msg,
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                    }
                    admin.btnLoading('[lay-filter="noticeBtn"]', false);
                    admin.removeLoading('#loading', true, true);
                }, error: function () {
                    notice.error({
                        title: 'SF提示您',
                        message: '服务器错误，请稍后重试~',
                        animateInside:true,
                        position:'topCenter',
                        transitionOut:'flipOutX',
                        transitionOutMobile: 'flipOutX',
                        timeout:false,
                        displayMode:'2',
                        audio:'1'
                    });
                    admin.btnLoading('[lay-filter="noticeBtn"]', false);
                    admin.removeLoading('#loading', true, true);
                    return false;
                }
            });
        });
    });
</script>
</body>
</html>